<cfparam name="Payment_ID" type="integer" />

<cfscript>
	paymentGateway = new assets.calgrants.com.gateway.PaymentGateway();
	payment = paymentGateway.get(Payment_ID = Payment_ID);
</cfscript>

<cfif payment.getPayment_ID() gt 0>
	
	<cfscript>
		base = new assets.calgrants.com.Base();
		scholarshipGateway = new assets.calgrants.com.gateway.ScholarshipGateway();
		scholarship = scholarshipGateway.get(Scholarship_ID = payment.getScholarship_ID());
		isPBS = base.isPBSScholarshipType(Scholarship_Type = scholarship.getScholarship_Type());
		institutionGateway = new assets.calgrants.com.gateway.InstitutionGateway();
		institution1 = institutionGateway.get(Institution_ID = payment.getInstitution1_ID());
		institution2 = institutionGateway.get(Institution_ID = payment.getInstitution2_ID());
		institution3 = institutionGateway.get(Institution_ID = payment.getInstitution3_ID());
		paymentScheduleGateway = new assets.calgrants.com.gateway.PaymentScheduleGateway();
		paymentSchedule = paymentScheduleGateway.get(Payment_Schedule_ID = payment.getPayment_Schedule_ID());
	</cfscript>
	
	<style type="text/css">
		.printable {
			max-width: 800px;
			margin-top: 20px;
			margin-left: 20px;
		}
		h1, h2, h3, h4, h5 {
			color: black;
		}
		th {
			text-align: left;
		}
		.well {
			width: 310px;
			min-height: 100%;
		}
	</style>

	<cfoutput>
	
		<div class="printable">
		
			<img src="common/images/Cash_for_College_logo.gif" width="204" height="54" style="margin-bottom: 15px;">
		
			<h2>Cash for College Payment Authorization</h2>
			
			<!--- <cfif fund.getApproved() eq 0>
				<div class="alert alert-error">
					<button type="button" class="close" data-dismiss="alert">&times;</button>
					This Site Support Funds Request is not approved
				</div>
			</cfif> --->
			
			<h4>Scholarship Payment ###payment.getPayment_ID()#</h4>

			<h4>#DateFormat(now(), "mmmm d, yyyy")#</h4>

			<div class="clearfix">
			
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
					<tr valign="top">
						<td width="50%">
						
							<h4>Recipient</h4>
							<div class="well">
								<strong>#scholarship.getFirst_Name()# #scholarship.getLast_Name()#</strong><br />
								#scholarship.getAddress()#<br />
								#scholarship.getCity()#, CA #scholarship.getZip_Code()#<br />							
								<cfif Len(Trim(scholarship.getPhone1())) gt 0>
									#base.formatPhone(scholarship.getPhone1())# (home)<br />
								</cfif>
								<cfif Len(Trim(scholarship.getPhone2())) gt 0>
									#base.formatPhone(scholarship.getPhone2())# (cell)<br />
								</cfif>
								<cfif Len(Trim(scholarship.getEmail())) gt 0>
									<a href="mailto:#LCase(scholarship.getEmail())#">#LCase(scholarship.getEmail())#</a><br />
								</cfif>
							</div>
							
							<h4>Primary College/University</h4>
							<div class="well">
								<strong>#institution1.getInstitution()#</strong><br />
								<cfif institution1.getDeleted() eq 1>
									<p class="text-error">This college/university is deleted</p>
								<cfelseif institution1.getDisqualified() eq 1>
									<p class="text-error">This college/university is disqualified</p>
								<cfelseif institution1.getApproved() eq 0>
									<p class="text-error">This college/university is unapproved</p>
								</cfif>
								<cfif Len(Trim(institution1.getFAO_City())) gt 0>
									#institution1.getFAO_City()#, #institution1.getFAO_State()#<br />
								</cfif>
								<cfif Len(Trim(institution1.getFAO_First_Name())) gt 0 or Len(Trim(institution1.getFAO_Last_Name())) gt 0>
									#institution1.getFAO_First_Name()# #institution1.getFAO_Last_Name()#<br />
								</cfif>
								<cfif Len(Trim(institution1.getFAO_Phone())) gt 0>
									#base.FormatPhone(institution1.getFAO_Phone())#<br />
								</cfif>
								<cfif Len(Trim(institution1.getFAO_Email())) gt 0>
									<a href="mailto:#LCase(institution1.getFAO_Email())#">#LCase(institution1.getFAO_Email())#</a><br />
								</cfif>
								<br />This is a #LCase(institution1.getTerm_Type())#-based school<br />
								<br />
								<table width="100%" cellpadding="2" cellspacing="2">
									<tr>
										<th>
											<cfif paymentSchedule.getVerification_Type() eq "enrollment">
												Class Schedule Received&nbsp;&nbsp;&nbsp;&nbsp;
											<cfelseif paymentSchedule.getVerification_Type() eq "performance">
												Transcript Received&nbsp;&nbsp;&nbsp;&nbsp;
											</cfif>
										</th>
										<td>
											<cfif IsDate(payment.getInstitution1_Document_Date())>
												#DateFormat(payment.getInstitution1_Document_Date(), "m/d/yyyy")#
											<cfelse>
												No
											</cfif>
										</td>
									</tr>
									<cfif paymentSchedule.getVerification_Type() eq "enrollment">
										<cfif isPBS>
											<tr>
												<th>Units</th>
												<td>
													<cfif IsNumeric(payment.getInstitution1_Enrollment_Units())>
														#payment.getInstitution1_Enrollment_Units()#
													<cfelse>
														No data
													</cfif>
												</td>
											</tr>
										<cfelse>
											<tr>
												<th>Attendance Level</th>
												<td>
													<cfif Len(Trim(payment.getInstitution1_Enrollment_Attendance_Level())) gt 0>
														#payment.getInstitution1_Enrollment_Attendance_Level()#
													<cfelse>
														No data
													</cfif>
												</td>
											</tr>
										</cfif>
										<tr>
											<th>Degree Level</th>
											<td>
												<cfif Len(Trim(payment.getInstitution1_Enrollment_Degree_Level())) gt 0>
													#payment.getInstitution1_Enrollment_Degree_Level()#
												<cfelse>
													No data
												</cfif>
											</td>
										</tr>
									<cfelseif paymentSchedule.getVerification_Type() eq "performance">
										<tr>
											<th>Credits</th>
											<td>
												<cfif IsNumeric(payment.getInstitution1_Performance_Credits())>
													#payment.getInstitution1_Performance_Credits()#
												<cfelse>
													No data
												</cfif>
											</td>
										</tr>
										<tr>
											<th>GPA</th>
											<td>
												<cfif IsNumeric(payment.getInstitution1_Performance_GPA())>
													#payment.getInstitution1_Performance_GPA()#
												<cfelse>
													No data
												</cfif>
											</td>
										</tr>
									</cfif>
								</table>
							</div>
							<cfif IsNumeric(scholarship.getInstitution2_ID()) and scholarship.getInstitution2_ID() gt 0>
								<h4>Secondary College/University</h4>
								<div class="well">
									<strong>#institution2.getInstitution()#</strong><br />
									<cfif institution2.getDeleted() eq 1>
										<p class="text-error">This college/university is deleted</p>
									<cfelseif institution2.getDisqualified() eq 1>
										<p class="text-error">This college/university is disqualified</p>
									<cfelseif institution2.getApproved() eq 0>
										<p class="text-error">This college/university is unapproved</p>
									</cfif>
									<cfif Len(Trim(institution2.getFAO_City())) gt 0>
										#institution2.getFAO_City()#, #institution2.getFAO_State()#<br />
									</cfif>
									<cfif Len(Trim(institution2.getFAO_First_Name())) gt 0 or Len(Trim(institution2.getFAO_Last_Name())) gt 0>
										#institution2.getFAO_First_Name()# #institution2.getFAO_Last_Name()#<br />
									</cfif>
									<cfif Len(Trim(institution2.getFAO_Phone())) gt 0>
										#base.FormatPhone(institution2.getFAO_Phone())#<br />
									</cfif>
									<cfif Len(Trim(institution2.getFAO_Email())) gt 0>
										<a href="mailto:#LCase(institution2.getFAO_Email())#">#LCase(institution2.getFAO_Email())#</a><br />
									</cfif>
									<br />This is a #LCase(institution2.getTerm_Type())#-based school<br />
									<br />
									<table width="100%" cellpadding="2" cellspacing="2">
										<tr>
											<th>
												<cfif paymentSchedule.getVerification_Type() eq "enrollment">
													Class Schedule Received&nbsp;&nbsp;&nbsp;&nbsp;
												<cfelseif paymentSchedule.getVerification_Type() eq "performance">
													Transcript Received&nbsp;&nbsp;&nbsp;&nbsp;
												</cfif>
											</th>
											<td>
												<cfif IsDate(payment.getInstitution2_Document_Date())>
													#DateFormat(payment.getInstitution2_Document_Date(), "m/d/yyyy")#
												<cfelse>
													No
												</cfif>
											</td>
										</tr>
										<cfif paymentSchedule.getVerification_Type() eq "enrollment">
											<cfif isPBS>
												<tr>
													<th>Units</th>
													<td>
														<cfif IsNumeric(payment.getInstitution2_Enrollment_Units())>
															#payment.getInstitution2_Enrollment_Units()#
														<cfelse>
															No data
														</cfif>
													</td>
												</tr>
											<cfelse>
												<tr>
													<th>Attendance Level</th>
													<td>
														<cfif Len(Trim(payment.getInstitution2_Enrollment_Attendance_Level())) gt 0>
															#payment.getInstitution2_Enrollment_Attendance_Level()#
														<cfelse>
															No data
														</cfif>
													</td>
												</tr>
											</cfif>
											<tr>
												<th>Degree Level</th>
												<td>
													<cfif Len(Trim(payment.getInstitution2_Enrollment_Degree_Level())) gt 0>
														#payment.getInstitution2_Enrollment_Degree_Level()#
													<cfelse>
														No data
													</cfif>
												</td>
											</tr>
										<cfelseif paymentSchedule.getVerification_Type() eq "performance">
											<tr>
												<th>Credits</th>
												<td>
													<cfif IsNumeric(payment.getInstitution2_Performance_Credits())>
														#payment.getInstitution2_Performance_Credits()#
													<cfelse>
														No data
													</cfif>
												</td>
											</tr>
											<tr>
												<th>GPA</th>
												<td>
													<cfif IsNumeric(payment.getInstitution2_Performance_GPA())>
														#payment.getInstitution2_Performance_GPA()#
													<cfelse>
														No data
													</cfif>
												</td>
											</tr>
										</cfif>
									</table>
									
									
								</div>
							</cfif>
						</td>
						<td width="50%">
						
							<h4>Scheduled Payment</h4>
							<div class="well">
								<table width="100%" cellpadding="2" cellspacing="2">
									<tr>
										<th>Scholarship Type</th>
										<td>#paymentSchedule.getScholarship_Type()#</td>
									</tr>
									<tr>
										<th>Verification Type</th>
										<td>#paymentSchedule.getVerification_Type()#</td>
									</tr>
									<tr>
										<th>Term Type</th>
										<td>#paymentSchedule.getTerm_Type()#</td>
									</tr>
									<tr>
										<th>Term</th>
										<td>#paymentSchedule.getTerm()#</td>
									</tr>
									<tr>
										<th>Scheduled Amount&nbsp;&nbsp;&nbsp;&nbsp;</th>
										<td>#DollarFormat(paymentSchedule.getPayment_Amount())#</td>
									</tr>
								</table>
							</div>
							
							<h4>Payment</h4>
							<div class="well">
								<table width="100%" cellpadding="2" cellspacing="2">
									<cfif payment.getOpt_Out() eq 0>
										<tr>
											<th>Approval Date</th>
											<td>
												<cfif IsDate(payment.getApproval_Date())>
													#payment.getApproval_Date()#
												<!--- <cfelse>
													Not approved --->
												</cfif>
											</td>
										</tr>
										<tr>
											<th>Submitted Date</th>
											<td>
												<cfif IsDate(payment.getPayment_Submitted_Date())>
													#payment.getPayment_Submitted_Date()#
												<!--- <cfelse>
													Not submited --->
												</cfif>
											</td>
										</tr>
										<tr>
											<th>Payment Date</th>
											<td>
												<cfif IsDate(payment.getPayment_Submitted_Date())>
													#payment.getPayment_Date()#
												<!--- <cfelse>
													Not paid --->
												</cfif>
											</td>
										</tr>
										<tr>
											<th>Payment Type</th>
											<td>#payment.getPayment_Type()#</td>
										</tr>
										<tr>
											<th>Payment Amount</th>
											<td>
												<cfif IsNumeric(payment.getPayment_Amount())>
													#DollarFormat(payment.getPayment_Amount())#
												</cfif>
											</td>
										</tr>
										<tr>
											<th>Payment Reference</th>
											<td>#payment.getPayment_Reference()#</td>
										</tr>
									<cfelse>
										<tr>
											<td colspan="2">
												<p>No payment</p>
												<p>#payment.getOpt_Out_Reason()#</p>
											</td>
										</tr>
									</cfif>
									<tr>
										<th>Notes</th>
										<td>#payment.getNotes()#</td>
									</tr>
								</table>
							</div>
													
						</td>
					</tr>
				</table>
			
			</div>
			<div class="clearfix">
			<br />
				<table>
					<tr>
						<th>Approved By</th>
						<td>______________________________________________________________________________</td>
					</tr>
					<tr>
						<td colspan="2"><br /><br /></td>
					</tr>
					<tr>
						<th>Date</th>
						<td>______________________________________________________________________________</td>
					</tr>
				</table>
			</div>
		</div>
		
	</cfoutput>
	
<cfelse>

	<div class="alert alert-info notFound">Payment not found</div>
	
</cfif>
